<?php
if (!defined ('TYPO3_MODE')) 	die ('Access denied.');

	//Класс который отрисовывает поля для выбора групп товаров на которые назначается скидка
require_once(t3lib_extMgm::extPath('user_farm_commerce').'TCEforms/class.user_discountCategories_TCEforms.php');
	//Класс который отрисовывает поля для выбора товаров на которые назначется скидка
require_once(t3lib_extMgm::extPath('user_farm_commerce').'TCEforms/class.user_discountProducts_TCEforms.php');

$TCA["user_farm_commerce_discounts"] = array (
	"ctrl" => $TCA["user_farm_commerce_discounts"]["ctrl"],
	"interface" => array (
		"showRecordFieldList" => ""
	),
	"feInterface" => $TCA["user_farm_commerce_discounts"]["feInterface"],
	"columns" => array (
		"discount_branch" => array(
			"exclude" => 0,
			"label" => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.branch',
			"config" => array(
				"type" => 'select',
				"items" => array(
					array('LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.branch_all', -1),
					array('LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.branch_personal', -2),
					array('', '--div--')
				),
				"foreign_table" => "user_farm_branches",
				"size" => 1,
				"maxitems" => 1,
				"minintems" => 1,
				"exclusiveKeys" => '-1,-2'
			)
		),
		'is_opt' => array(
			"exclude" => 1,
			"label" => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.isOpt',
			"config" => array(
				"type" => 'radio',
				"items" => array(
					array(
						'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.isOpt.rozn',
						0
					),
					array(
						'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.isOpt.opt',
						1
					)
				),
				"default" => 0
			)
		),
		'discount_users' => array(
			"exclude" => 0,
			"label" => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.users',
			"displayCond" => "FIELD:discount_branch:=:-2",
			"config" => array(
				"type" => "select",
				"foreign_table" => "fe_users",
				"size" => 5,
				"minitems" => 0,
				"maxitems" => 30
			)
		),
		'discount_type' => array(
			"exclude" => 0,
			"label" => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.type',
			"config" => array(
				"type" => 'select',
				'items' => array(
					array('LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.type_categories', 1),
					array('LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.type_products', 2),
					array('LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.type_manafacturers', 3)
				),
				'size' => 1,
				'maxitems' => 1,
				'minitems' => 1
			)
		),
		'categories' => array(
			'exclude' => 0,
			'label' => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.categories',
			'config' => array(
				'type' => 'user',
				'userFunc' => 'user_discountCategories_TCEforms->user_getDiscountCategoriesField'
			)
		),
		'products' => array(
			'exclude' => 0,
			'label' => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.products',
			'config' => array(
				'type' => 'user',
				'userFunc' => 'user_discountProducts_TCEforms->user_getDiscountProductsField'
			)
		),
		'manufacturers' => array(
			'exclude' => 0,
			'label' => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.manufacturers',
			'config' => array(
				'type' => 'select',
				'foreign_table' => 'tx_commerce_manufacturer',
				'size' => 5,
				'minitems' => 0,
				'maxitems' => 30
			)
		),
		'discount' => array(
			'exclude' => 0,
			'label' => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.discount',
			'config' => array(
				'type' => 'input',
				'size' => '5',
				'max' => '5',
				'eval' => 'required,double2',
				'range' => array(
					'lower' => 0.01,
					'upper' => 99.99
				)
			)
		)
	),
	"types" => array (
		"1" => array("showitem" => "--div--;LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.commonTab;;;1-1-1, discount_branch, discount_users, discount_type;;;;2-2-2, is_opt, discount, --div--;LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.categoryTab;;;3-3-3, categories"),
        "2" => array("showitem" => "--div--;LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.commonTab;;;1-1-1, discount_branch, discount_users, discount_type;;;;2-2-2, is_opt, discount, --div--;LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.productsTab;;;3-3-3, products"),
        "3" => array("showitem" => "--div--;LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.commonTab;;;1-1-1, discount_branch, discount_users, discount_type;;;;2-2-2, is_opt, discount, --div--;LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts.manufacturersTab;;;3-3-3, manufacturers"),
	),
	"palettes" => array (
		"1" => array("showitem" => "")
	)
);
?>